<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/28
 * Time: 9:09
 */

namespace app\api\controller\v1;
use app\api\model\Banner as BannerModel;
use app\api\validate\IDMustBePostiveInt;
use app\lib\exception\BannerMissException;
use think\Exception;

class Banner
{
    /*
     * 获取banner
     * @url /banner/:id
     * @http GET
     * @id banner id号
     * */
    public function getBanner($id)
    {
        //面向切面编程 AOP
        (new IDMustBePostiveInt())->goCheck();
        //$banner = BannerModel::with(['items', 'items.img'])->find($id);
        //get find all select
        $banner = BannerModel::getBannerByID($id);
        if (!$banner){
            throw new BannerMissException();
        }
        $c = config('setting.img_prefix');

        return $banner;
    }

}